package com.cs.paoyer.common.validator;

import java.text.SimpleDateFormat; 
import java.util.Date;
import com.cs.paoyer.common.exception.UserException;
import com.cs.paoyer.common.exception.CommonUserException;



public class FieldValidator {

  public FieldValidator() 
	{
  }
  
  public static void validateString (String str)
  {
    
    if ( (str == null)||(str.equals(""))  )
		{
				throw new UserException(new CommonUserException().getModuleVO(), 
					CommonUserException.NOT_ALL_REQUIRED_FIELDS );
    }
    
  }
  
  public static void validateNumber(double num) 
	{   
			if(num==0)
			{
						 throw new UserException(new CommonUserException().getModuleVO(), 
						 CommonUserException.NOT_ALL_REQUIRED_FIELDS  );      
			}
    
  }

	public static void validateDate(String strDate)
	{   
	    try
			{
					SimpleDateFormat format = new SimpleDateFormat( "yyyy-MM-dd" ); 
					Date date = format.parse( strDate ); 
      }
			catch(Exception e)
			{
					throw new UserException(new CommonUserException().getModuleVO(), 
						 CommonUserException.INCORRECT_DATE_FORMAT  );     
			}
  }
  
  
    
  
}